const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}


// es6单列导出
export const showToast = (title,icon="none") => {
  wx.showToast({
  title,
  icon,
  duration:5000,
  mask:true
  })
}

export const showLoading = title =>{
    wx.showLoading({
      title:"拼命加载中",
      mask:true
    })
}
export const showModal = content =>{
  return new Promise((resolve,reject)=>{
    wx.showModal({
      title: '提示',
      content,
      success:({confirm}) => confirm?resolve():reject()
      // {
      //   if(confirm){
      //     resolve()
      //   }else{
      //     reject()
      //   }
      // }
    })
  })
}

// 当属性名和属性值一样时，可以简写
// module.exports = {
//   formatTime,
//   showToast
// }
